package model.ds.piece;

import java.util.ArrayList;
import model.PlayerColor;
import model.ds.PieceType;
import model.ds.GameBoard;
import model.ds.GameTile;
import model.HexDirection;
import common.Tuple;

/**
 * The general piece class. It supports the common operations for all types
 * of pieces. These incorporate the rule that the piece can only move if
 * the board remains connected.
 * @author Jan-Philipp Kappmeier
 */
public abstract class Piece {
	
	
	/**
	 * The unique id of this Piece which is set to i, if this Piece is placed as the i'th Piece in the game.
	 */
	protected final int id;
	
	/**
	 * The type of this Piece in order to get information about the multiplicity etc. of this object.
	 * This information is also needed for the display of a correct image in the graphic component.
	 */
	protected PieceType type;
	
	/**
	 * The player this object belongs to.
	 */
	protected PlayerColor color;

	/**
	 * Creates the instance of the piece with the given id and color.
	 * @param color the color of the piece
	 * @param id the id of the counter
	 * @param gb the game board on which the piece is placed
	 */
	public Piece( PlayerColor color, int id) {
		this.color = color;
		this.id = id;
	}

	/**
	 * Returns the color of the counter.
	 * @return the color of the counter
	 */
	public PlayerColor getColor() {
		return this.color;
	}

	/**
	 * Returns a list of all reachable hex fields for the specific counter. Has
	 * to be implemented by all counter types according to their specific rules.
	 * @param tile the tile on which the counter is placed
	 * @return a list containing the indices of the reachable hex fields
	 */
	public abstract ArrayList<Tuple<Integer,HexDirection>> getReachableFields(GameTile tile);


	
	public PieceType getType(){
		return this.type;
	}

}
